<script>
    export let clazz = '';
    export let config_sub = false;
    let mapper = {
        true: 1,
        false: 2
    }
    let show_sub = "";
    function switch_sub(){
        if(show_sub === 'show-sub'){
            show_sub = ""
        }
        else
        {
            show_sub = "show-sub"
        }
    }
</script>
<main class="panel {clazz}" on:click={switch_sub}>
    <div class="card-main">
        <slot/>
    </div>
    <div class="badge">
        <slot name="badge">卡片</slot>
    </div>
    {#if (!!show_sub) && config_sub}
        <div class="sub-lst">
            <slot name="sub-lst">

            </slot>
        </div>
    {/if}
</main>

<style lang="less">
  .sub-lst {
    position: absolute;
    top: -10px;
    background: white;

    padding: 15px 10px;
    min-width:120px ;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), /* 鼠标悬停时加深阴影 */ 0 8px 30px rgba(0, 0, 0, 0.19);
  }

  :global(.sub-item) {
    width: 100%;
    box-sizing: border-box;
    margin: 3px auto;
    cursor: pointer;
    user-select: none;
    padding: 5px 5px;
    font-size: 12px;
    &:hover {
      background: #7daee0CC;
      color: blue;
    }
  }
  @keyframes show-sub-frame {
    0% {
      transform: scale(0);
      opacity: 0;
    }

    100% {
      transform: scale(1);
      opacity: 1;
    }
  }
  .sub-lst{
    animation: show-sub-frame ease-in .3s;
    transform-origin: top left;
  }

  .panel {
    background: white;
    border-radius: 5px;
    position: relative;
    text-align: center;
    margin: 0;
    width: fit-content;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), /* 底部阴影 */ 0 6px 20px rgba(0, 0, 0, 0.19); /* 扩散较广的阴影 */
    transition: box-shadow 0.3s ease;
    box-sizing: border-box;
    padding: 10px 20px;
    top: 0;
    transition: .3s;

    &:hover {
      top: -10px;
      box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), /* 鼠标悬停时加深阴影 */ 0 8px 30px rgba(0, 0, 0, 0.19);
    }
  }

  .panel-top {
    &:hover {
      top: 10px !important;
      box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), /* 鼠标悬停时加深阴影 */ 0 8px 30px rgba(0, 0, 0, 0.19);
    }
  }

  .badge {
    position: absolute;
    top: 14px;
    right: 13px;
    font-size: 13px;
    z-index: 1;
  }

  .tags {
    padding: 2px 15px;

  }

  :global(.row-card) {
    display: flex;

    height: 100px;
    width: 300px;
    gap: 20px;
  }
  :global(.badge-building) {
      .tags;
    background: #7daee0;
    border: #7daee0 1px solid;
    color: white;
    transition: 2s;
    position: relative;
    top: -25px;
    left: 15px;
  }
  :global(.badge-chara) {
      .tags;
    background: #EE82EEFF;
    border: #5d215d 1px solid;
    color: white;
  }

  :global(.badge-resource) {
      .tags;
    background: #8d82ee;
    border: #21395d 1px solid;
    color: white;
  }
</style>